package com.jt.websoket;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "1.websoket接口")
@RestController
@RequestMapping("/websoket")
public class WebSocketTest {

    @Resource
    private WebSocket webSocket;
    @ApiOperation("01.群发消息")
    @GetMapping("/sendallmsg")
    public String sendallmsg(String msg) {
        webSocket.sendAllMessage(msg);
        return "发送成功";
    }

    @ApiOperation("02.给某个用户发消息")
    @GetMapping("/sendonemsg")
    public String sendallmsg(String userId,String msg) {
        webSocket.sendOneMessage(userId,msg);
        return "发送成功";
    }


}
